// components/SwipeToNavigate.kt
package com.trumeen.immichgallery.ui.components

import androidx.compose.foundation.gestures.detectHorizontalDragGestures
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.geometry.Offset
import kotlin.math.abs

fun Modifier.swipeToNavigate(
    onSwipeLeft: () -> Unit,
    onSwipeRight: () -> Unit,
    swipeThreshold: Float = 50f
): Modifier = this.pointerInput(Unit) {
    detectHorizontalDragGestures { change, dragAmount ->
        when {
            dragAmount < -swipeThreshold -> {
                onSwipeLeft()
                change.consume()
            }
            dragAmount > swipeThreshold -> {
                onSwipeRight()
                change.consume()
            }
        }
    }
}